//
//  PHAsset+Description.swift
//  ai_assettool
//
//  Created by 李旭峰 on 2021/4/10.
//

import Foundation
import Photos

extension PHAsset : AICustomStringConvertible {
    var aiDescription: String {
        var desc = ""
        desc += "playbackStyle : \(self.playbackStyle.aiDescription) \n"
        desc += "mediaType : \(self.mediaType.aiDescription) \n"
        desc += "mediaSubtypes : \(self.mediaSubtypes.aiDescription) \n"
        desc += "isHidden : \(self.isHidden.aiDescription)\n"
        desc += "isFavorite : \(self.isFavorite.aiDescription)\n"
        desc += "burstIdentifier : \(self.burstIdentifier?.aiDescription ?? "nil")\n"
        desc += "sourceType : \(self.sourceType.aiDescription)\n"
        desc += "creationDate : \(self.creationDate?.aiDescription ?? "nil")\n"
        desc += "modificationDate : \(self.modificationDate?.aiDescription ?? "nil")\n"
        desc += "localIdentifier : \(self.localIdentifier.aiDescription)\n"
        self.requestPath { (path) in
            print("asset - request path - \(path ?? ": path is nil")")
        }
        return desc
    }
    
}
extension PHAsset.PlaybackStyle : AICustomStringConvertible {
    public var aiDescription: String {
        switch self {
        case .unsupported:return "unsupported - \(self.rawValue)"
        case .image:return "image - \(self.rawValue)"
        case .imageAnimated:return "imageAnimated - \(self.rawValue)"
        case .livePhoto:return "livePhoto - \(self.rawValue)"
        case .video:return "video - \(self.rawValue)"
        case .videoLooping:return "videoLooping - \(self.rawValue)"
        default:return "unknown - \(self.rawValue)"
        }
    }
}
extension PHAssetMediaType : AICustomStringConvertible {
    public var aiDescription: String {
        switch self {
        case .audio:return "audio - \(self.rawValue)"
        case .video:return "video - \(self.rawValue)"
        case .image:return "image - \(self.rawValue)"
        case .unknown:return "unknown - \(self.rawValue)"
        default:return "unknown - \(self.rawValue)"
        }
    }
}
extension PHAssetMediaSubtype : AICustomStringConvertible {
    public var aiDescription: String {
        switch self {
        case .photoPanorama:return "photoPanorama - \(self.rawValue)"
        case .photoHDR:return "photoHDR - \(self.rawValue)"
        case .photoScreenshot:return "photoScreenshot - \(self.rawValue)"
        case .photoLive:return "photoLive - \(self.rawValue)"
        case .photoDepthEffect:return "photoDepthEffect - \(self.rawValue)"
        case .videoStreamed:return "videoStreamed - \(self.rawValue)"
        case .videoHighFrameRate:return "videoHighFrameRate - \(self.rawValue)"
        case .videoTimelapse:return "videoTimelapse - \(self.rawValue)"
        default:return "unknow - \(self.rawValue)"
        }
    }
}

extension PHAssetSourceType : AICustomStringConvertible {
    public var aiDescription: String {
        switch self {
        case .typeUserLibrary:return "typeUserLibrary - \(self.rawValue)"
        case .typeCloudShared:return "typeCloudShared - \(self.rawValue)"
        case .typeiTunesSynced:return "typeiTunesSynced - \(self.rawValue)"
        default:return "unknown - \(self.rawValue)"
        }
    }
}
